]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
systemActions: Filter out empty (folded) terms
authorFlorian Müllner <fmuellner@gnome.org>
Sat, 12 Sep 2020 16:32:57 +0000 (18:32 +0200)
committerFlorian Müllner <florian.muellner@gmail.com>
Mon, 14 Sep 2020 21:10:58 +0000 (21:10 +0000)
We split the search string into words using whitespace, while
GLib.tokenize_and_fold() splits on any non-alphanumeric characters.

That is, a valid search term like ',' will be tokenized as [], so
the original non-empty terms may get mapped to an empty array.

And as [].every() returns true for any condition[0], we end up
matching *all* system actions in that case. We want the exact
opposite and not return any results, so handle that case explicitly.

[0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3169

js/misc/systemActions.js

index 4c2f3a29051bb206910fe5f88e0940c998bf78d5..1cd65764885820cb7f6f135f0744563fda3de79d 100644 (file)
@@ -269,6 +269,10 @@ const SystemActions = GObject.registerClass({
         terms = terms.map(
             term => GLib.str_tokenize_and_fold(term, null)[0]).flat(2);
 
+        // tokenizing may return an empty array
+        if (terms.length === 0)
+            return [];
+
         let results = [];
 
         for (let [key, { available, keywords }] of this._actions) {